<template>
  <div class="container">

    <el-row class="el-row-2">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>主页</el-breadcrumb-item>
        <el-breadcrumb-item>人事管理</el-breadcrumb-item>
        <el-breadcrumb-item>档案管理</el-breadcrumb-item>
      </el-breadcrumb>
    </el-row>
    <el-row class="el-row-2">
      <el-col :span="24">


       <el-form label-width="60px">

         <el-row style="width: 100%">
           <el-col :span="8">
             <el-form-item label="姓名">
               <el-input></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="备注">
               <el-input></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="8">
           <el-form-item label="类别">
             <el-select></el-select>
           </el-form-item>
           </el-col>
         </el-row>
         <el-row style="width: 100%">
           <el-col :span="8">
             <el-form-item label="姓名">
               <el-input></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="备注">
               <el-input></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item >
               <el-button type="success">搜索</el-button>
             </el-form-item>
           </el-col>
         </el-row>

       </el-form>
      </el-col>
    </el-row>
    <el-row>

      <el-button-group>
        <el-button type="success" @click="btnAddClick"> 添加</el-button>
        <el-button type="info">其他</el-button>
      </el-button-group>
      <el-table
          :data="data.items">
        <el-table-column type="selection" width="30"></el-table-column>
        <el-table-column type="index" label="序号" width="60"></el-table-column>
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column prop="desc" label="备注"></el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <el-button type="warning" @click="btnEditClick(scope.row)">修改</el-button>
            <el-button type="danger">删除</el-button>
            <el-button type="info">其他</el-button>
          </template>
        </el-table-column>

      </el-table>
      <el-pagination
          small
          background
          layout="prev, pager, next"
          :total="50"
          class="mt-4"
      />

    </el-row>



      <el-dialog v-model="data.info.isShow">
         <template #title>{{ data.info.title }}</template>

          <el-form>
             <el-form-item label="姓名">
                 <el-input v-model="data.info.item.name"></el-input>
             </el-form-item>
            <el-form-item label="备注">
              <el-input  v-model="data.info.item.desc"></el-input>
            </el-form-item>

            <el-form-item >
              <el-button>保存</el-button>
            </el-form-item>

          </el-form>

      </el-dialog>


  </div>
</template>

<script setup lang="ts">

import {reactive} from "vue";

const data = reactive({
  items: [
    {
      id: 1,
      name: 'Martin',
      desc: 'ddddadiuiui'
    }, {
      id: 2,
      name: 'Lee',
      desc: 'ddttvv'
    }
  ],info:{
      isShow:false,
      title:'添加信息',
      item:{
         name:'',
         desc:''
      }
  }
})

const btnAddClick = ()=>{
     data.info.isShow=true;

}

const btnEditClick=(row)=>{
   data.info.title="修改信息";
   data.info.item.name = row.name;
  data.info.item.desc = row.desc;

  data.info.isShow=true;
}

</script>

<style scoped>

.el-row-2{
    padding-bottom: 10px;
}

.container{
   padding: 15px;
}
</style>